package com.han.hotelplat.controller.hotel;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;

import com.han.hotelplat.comm.ResponseWrapTo;
import com.han.hotelplat.comm.ResponseWrapTo.CodeType;
import com.han.hotelplat.pojo.hotel.Hotel;
import com.han.hotelplat.pojo.hotelroom.HotelRoom;
import com.han.hotelplat.service.hotel.HotelService;
import com.han.hotelplat.service.hotelroom.HotelRoomService;

@Controller
@RequestMapping("/hotel/*")
public class HotelController {
	@Autowired
	private HotelService hotelService;
	@Autowired
	private HotelRoomService hotelRoomService;
	
	@ResponseBody
	@RequestMapping(value = "getAllHotel", produces = "application/json;charset=UTF-8", method = { RequestMethod.POST,RequestMethod.GET })
	public String getAllHotel() {
		List<Hotel> data = hotelService.getAllHotel();
		return new ResponseWrapTo(CodeType.success,"数据获取成功",data).toJson();
	}
	
	/**
	 * 
		 * @description	根据酒店ID获取酒店信息
		 * @author  han1088
		 * @param hotelid
		 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "getHotel", produces = "application/json;charset=UTF-8", method = { RequestMethod.POST,RequestMethod.GET })
	public String getHotel(Integer hotelId) {
		Hotel data = hotelService.getHotelById(hotelId);
		return new ResponseWrapTo(CodeType.success,"数据获取成功",data).toJson();
	}
	
	/**
	 * 
		 * @description	上传酒店资料
		 * @author  han1088
		 * @param request
		 * @param facepic 门头照
		 * @param licensepic 营业执照
		 * @param roompic 房间照片
		 * @return
	 */
	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping(value = "saveHotel", produces = "application/json;charset=UTF-8", method = { RequestMethod.POST,RequestMethod.GET })
	public String saveHotel(HttpServletRequest request,Hotel hotel){
		/*Map<String, Object> reMap = hotelService.saveHotel(hotel, "");
		int code = (int) reMap.get("code");
		String message = (String) reMap.get("message");*/
		return new ResponseWrapTo(-1, "接口已经废弃",null).toJson();
	}
	
	@SuppressWarnings("unchecked")
	@ResponseBody
	@RequestMapping(value = "getHotelRoom", produces = "application/json;charset=UTF-8", method = { RequestMethod.POST,RequestMethod.GET })
	public String getHotelRoom(Integer hotelId){
		List<HotelRoom> re = hotelRoomService.findHotelRoomByHotelId(hotelId);
		return new ResponseWrapTo(CodeType.success, "数据获取成功",re).toJson();
	}
	
}
